package controllers

import (
	"github.com/astaxie/beego"
	"analysis-ss/models"
	"analysis-ss/dao"
)

type MainController struct {
	beego.Controller
}

//// 获得中心数据
//func (c *MainController) TeacherData() {
//	//获得条件参数
//	centerId := c.GetString("centerId")
//	teacherName := c.GetString("teacherName")
//	start, err := c.GetInt("start")
//	if err != nil {
//		start = 0
//	}
//	length, err := c.GetInt("length")
//	if err != nil {
//		length = 10
//	}
//	// 计算总页数
//	Total, err := dao.QueryTeacherTotal(centerId, teacherName)
//	s := make(map[string]interface{})
//	s["start"] = start
//	s["length"] = length
//	s["recordsTotal"] = Total
//	s["recordsFiltered"] = Total
//	s["data"] = teacherList(centerId, teacherName, start, length)
//	c.Data["json"] = s
//	c.ServeJSON()
//}
//
//// 获得中心数据
//func (c *MainController) CenterData() {
//	// 获得条件参数
//	centerId := c.GetString("centerId")
//	// 分页
//	start, err := c.GetInt("start")
//	if err != nil {
//		start = 0
//	}
//	length, err := c.GetInt("length")
//	if err != nil {
//		length = 10
//	}
//	// 计算总页数
//	Total, err := dao.QueryCenterTotal(centerId)
//	s := make(map[string]interface{})
//	s["start"] = start
//	s["length"] = length
//	s["recordsTotal"] = Total
//	s["recordsFiltered"] = Total
//	s["data"] = centerList(centerId, start, length)
//	c.Data["json"] = s
//	c.ServeJSON()
//}

// 中心页面
func centerList(centerId string, start, length int) []models.Center {
	// 查询所有的中心
	centers, _, err := dao.QueryCenter(centerId, start, length)
	if err != nil {
		beego.Debug(err)
	}
	return centers
}

func teacherList(centerId string, teacherName interface{}, start, length int) []models.Center {
	// 查询所有的中心
	teachers, _, err := dao.QueryTeacher(centerId, teacherName, start, length)
	if err != nil {
		beego.Debug(err)
	}
	return teachers
}
